
package com.jzdy.core.utils;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.jzdy.R;

public class CoreActivityHelper
{
    public static int DEFAULT_ENTER_ANIM = R.anim.activity_in;
    public static int DEFAULT_EXIT_ANIM = R.anim.activity_out;

    public static void startActivity(Activity activity , Class<?> clazz , Bundle bundle , boolean isAnimated , int enterAnim , int exitAnim , int... flags)
    {
        Intent intent = new Intent(activity, clazz);
        if (bundle != null)
        {
            intent.putExtras(bundle);
        }
        if (flags != null && flags.length > 0)
        {
            for (int i = 0; i < flags.length; i++)
            {
                intent.setFlags(flags[i]);
            }
        }
        activity.startActivity(intent);
        if (isAnimated)
        {
            activity.overridePendingTransition(enterAnim, exitAnim);
        }
    }

    public static void startActivity(Activity activity , Class<?> clazz , Bundle bundle)
    {
        Intent intent = new Intent(activity, clazz);
        if (bundle != null)
        {
            intent.putExtras(bundle);
        }
        activity.startActivity(intent);
        activity.overridePendingTransition(DEFAULT_ENTER_ANIM, DEFAULT_EXIT_ANIM);
    }

    public static void startActivity(Activity activity , Class<?> clazz)
    {
        Intent intent = new Intent(activity, clazz);
        activity.startActivity(intent);
        activity.overridePendingTransition(DEFAULT_ENTER_ANIM, DEFAULT_EXIT_ANIM);
    }
}
